docs(examples): add metadata filter operator snippets - #438
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
|
Update: I was able to complete the CLA from another device. The CLA check now shows signed. Thanks. |
There was a problem hiding this comment.
Pull request overview
Adds runnable, copy-pasteable TypeScript examples demonstrating metadata filter operators in the JavaScript examples package (examples/javascript/), aligning with the repo’s goal of providing practical SDK usage snippets.
Changes:
- Added four runnable operator-focused scripts for
$eq,$and,$in, and$nearunderexamples/javascript/metadata-filters/. - Introduced a shared helper to centralize setup (env, temporary index creation/loading), querying, and teardown.
- Updated the JavaScript examples README and
package.jsonscripts to make running the new samples straightforward.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| examples/javascript/README.md | Documents the new metadata filter operator samples and how to run them. |
| examples/javascript/package.json | Adds npm run metadata:* scripts to run each operator snippet. |
| examples/javascript/metadata-filters/shared.ts | Shared runner that creates a temporary index, performs a filtered query, prints results, and cleans up. |
| examples/javascript/metadata-filters/eq.ts | Runnable $eq filter example. |
| examples/javascript/metadata-filters/and.ts | Runnable $and composition example. |
| examples/javascript/metadata-filters/in.ts | Runnable $in filter example. |
| examples/javascript/metadata-filters/near.ts | Runnable $near geo-distance filter example. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codex reviewNo issues found. |
…r-operator-examples
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded a shared temporary-index runner and four runnable JavaScript examples for ChangesMetadata filter examples
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to This PR adds localized metadata-filter examples and related documentation without any actionable merge-blocking risk remaining after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant OperatorExample
participant runMetadataFilterExample
participant Moss
participant TemporaryIndex
OperatorExample->>runMetadataFilterExample: provide metadata filter
runMetadataFilterExample->>Moss: create temporary index
Moss->>TemporaryIndex: load sample documents
runMetadataFilterExample->>TemporaryIndex: execute filtered hybrid query
TemporaryIndex-->>runMetadataFilterExample: return results
runMetadataFilterExample->>Moss: delete temporary index
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/javascript/metadata-filters/shared.ts`:
- Around line 71-81: Update the temporary index name construction in the
metadata filter example to use randomUUID() as its unique suffix instead of
Date.now(). Keep the existing operator-based prefix and cleanup flow unchanged.
- Around line 102-109: Update the cleanup flow in the surrounding try/finally
logic so deleteIndex’s Promise<boolean> result must be true; when no primary
error exists, propagate cleanup failures by rejecting on a thrown error or a
non-true result. Preserve the primary operation error when both the primary
operation and cleanup fail, and keep the existing cleanupNeeded guard and
warning behavior as appropriate.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a23bedd1-9a78-45aa-a8e1-d1fc3fc0cde4
📒 Files selected for processing (7)
examples/javascript/README.mdexamples/javascript/metadata-filters/and.tsexamples/javascript/metadata-filters/eq.tsexamples/javascript/metadata-filters/in.tsexamples/javascript/metadata-filters/near.tsexamples/javascript/metadata-filters/shared.tsexamples/javascript/package.json
Summary
$eq,$and,$in, and$nearunderexamples/javascript/metadata-filters/.Closes #417
Verification
npm cinpm run type-checknpm run lintgit diff --checkNotes
The examples require real
MOSS_PROJECT_IDandMOSS_PROJECT_KEYcredentials to run end-to-end. I verified them with the local TypeScript and ESLint checks; at runtime they create a temporary index, run one filtered query, and delete the index.Summary by CodeRabbit
New Features
Documentation
Chores